package com.jqsoft.launcher.patientdb;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * 建立患者人员数据库类
 *
 * @author gujunqi date：2014-3-31
 */
public class PatientDbOpenHelper extends SQLiteOpenHelper {
    public static final String PATIENT_DB_NAME = "patient.db";

    public PatientDbOpenHelper(Context context) {
        super(context, PATIENT_DB_NAME, null, 2);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // 创建高血压表格
        db.execSQL("create table highblood (sPersonID varchar(50) primary key ,"
                + " sNo varchar(50), sPersonName varchar(50),sSexName varchar(50), "
                + "dBirthday varchar(50),sCardNo varchar(50),sGradeName varchar(50),"
                + "sDiagnosedHospital varchar(50),dDiagnosedTime varchar(50),sInputDeptName varchar(50),"
                + "visitingCount varchar(50),healthyCheckUpCount varchar(50),iState varchar(50),beiyong1 varchar(50),beiyong2 varchar(50),sAreaCode varchar(50),sphoto text,sphoto1 text)");

		 
		/*
		 * String sPersonID; String sNo;//档案编号 String sPersonName;//姓名 String
		 * sSexName;//性别 String dBirthday;//出生日期（年龄需要计算） String sCardNo;//证件号码
		 * String sGradeName;//患病级别 String sDiagnosedHospital;//确诊医院 String
		 * dDiagnosedTime;//确诊时间 String sInputDeptName; //录入单位 String
		 * VisitingCount;//随访总次数 String HealthyCheckUpCount;//健康体检总次数 String
		 * iState;//是否管理（-1否 1是）
		 */
        // 创建糖尿病表格
        db.execSQL("create table diabetesmellitus (sPersonID varchar(50) primary key ,"
                + " sNo varchar(50), sPersonName varchar(50),sSexName varchar(50), "
                + "dBirthday varchar(50),sCardNo varchar(50),sGradeName varchar(50),"
                + "sDiagnosedHospital varchar(50),dDiagnosedTime varchar(50),sInputDeptName varchar(50),"
                + "visitingCount varchar(50),healthyCheckUpCount varchar(50),iState varchar(50),beiyong1 varchar(50),beiyong2 varchar(50),sAreaCode varchar(50),sphoto text,sphoto1 text)");

        // private String sNowDiagnosis;//目前诊断情况
        // private String TreatmentEffect;//最近一次治疗效果
        // private String dFillTime;//填表日期
        // private String sDoctorName;//医生姓名
        //
        // private String sInputDeptName; //录入机构名称
        // private String VisitingCount;//随访总次数
        // private String ExaminationCount;//体检总次数
        // private String iState;//是否管理（-1否 1是）

        // 创建重性精神病表格
        db.execSQL("create table majorpsychosis (sPersonID varchar(20) primary key ,"
                + " sNo varchar(20), sPersonName varchar(20),sSexName varchar(20), "
                + "dBirthday varchar(20),sCardNo varchar(20),sGuardianName varchar(20),"
                + "sNowDiagnosis varchar(20),treatmentEffect varchar(20),dFillTime varchar(20),"
                + "sDoctorName varchar(20),sInputDeptName varchar(20),visitingCount varchar(20),examinationCount varchar(20),iState varchar(20),sAreaCode varchar(50),sphoto text)");

        // private String sCardNo;//证件号码
        // private String sSexCode;//性别代码
        //
        // private String gKey;//主键
        // private String sPhone;//联系方式
        // private String sRegisterNo;//保健手册编码
        // private String dRegisterDate;//建册日期
        // 创建儿童表格
        db.execSQL("create table childcare (sPersonID varchar(20) primary key ,"
                + " sNo varchar(20), sPersonName varchar(20),sSexName varchar(20), "
                + "dBirthday varchar(20),sCardNo varchar(20),sSexCode varchar(20),"
                + "gKey varchar(20),sPhone varchar(20),sRegisterNo varchar(20),"
                + "dRegisterDate varchar(20),VisitingCount varchar(20),CIRsAreaCode varchar(20),sphoto text)");

        // private String sPersonID; //个人唯一标识
        // private String sNo;//档案编号
        // private String sPersonName;//姓名
        // private String sSexCode;//性别2代表女
        // private String dBirthday;//出生日期（年龄需要计算）
        // private String sCardNo;//证件号码
        // private String sPhone;//联系方式
        // private String iPregnancytime;//孕次
        // private String gKey;
        // private String iState;//是否管理（-1否 1是）
        // 创建孕产妇表格
        db.execSQL("create table pregnantwomen (sPersonID varchar(20) primary key ,"
                + " sNo varchar(20), sPersonName varchar(20),sSexCode varchar(20), "
                + "dBirthday varchar(20),sCardNo varchar(20),sPhone varchar(20),"
                + "iPregnancytime varchar(20),gKey varchar(20),iState varchar(20),"
                + "iPostpartumVisit varchar(20),sAreaCode varchar(20),sphoto text)");

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS highblood");
        db.execSQL("DROP TABLE IF EXISTS diabetesmellitus");
        db.execSQL("DROP TABLE IF EXISTS majorpsychosis");
        db.execSQL("DROP TABLE IF EXISTS childcare");
        db.execSQL("DROP TABLE IF EXISTS pregnantwomen");


        onCreate(db);

    }

}
